<?php
    require_once ("Includes/session.php");
    require_once ("Includes/simplecms-config.php"); 
    require_once ("Includes/connectDB.php");
    require_once ("Functions/scanresults.php");

    include("Includes/header.php"); 
    confirm_is_admin();
?>
    <div id="main">
    <h3>TESTING PAGE</h3>
        <ul>
        <?php
            if (!isset($_POST['submit']))
                echo "Select Test of Your Choice:";
            else if ($_POST['submit'] == 'Test getEventNameByID') {
                echo '<li>'.getEventNameByID(45).'</li>';
                echo '<li>'.getEventNameByID(24).'</li>';
            }
            else if ($_POST['submit'] == 'Test getTeamDetailsByID') {
                echo '<li>'.getTeamDetailsByID(0).'</li>';
                echo '<li>'.getTeamDetailsByID(1).'</li>';
                echo '<li>'.getTeamDetailsByID(2).'</li>';
            }
            else if ($_POST['submit'] == 'Test lookupSwimIDByName') {
                echo '<li>'.lookupSwimIDByName('nicholas', 'swenson').'</li>';
                echo '<li>'.lookupSwimIDByName('charlotte', 'swenson').'</li>';
                echo '<li>'.lookupSwimIDByName('Nick', 'Sweeeeney').'</li>';
            }
            else if ($_POST['submit'] == 'Test extractDate') {
                echo '<li>'.extractDate('2001 Santa Teresa @ Almaden - 6/16/01').'</li>';
                echo '<li>'.extractDate('5/19/01 2001 Santa Teresa @ Almaden - ').'</li>';
                echo '<li>'.extractDate('2001 Santa Teresa @ Almaden - 6/16/0').'</li>';
            }
            else if ($_POST['submit'] == 'Test extractTeamInfo') {
                $teams = extractTeamInfo('2001 Santa Teresa @ Almaden - 6/16/01');
                echo '<li>'.$teams[0].'</li>';
                echo '<li>'.$teams[1].'</li>';
                $teams = extractTeamInfo('2001 Creekside vs.Santa Teresa - 6/23/01');
                echo '<li>'.$teams[0].'</li>';
                echo '<li>'.$teams[1].'</li>';
            }
            else if ($_POST['submit'] == 'Test setupMetaDataFile') {
                echo '<li>'.strval(setupMetaDataFile('Bob')).'</li>';
                echo '<li>'.strval(setupMetaDataFile('Cabana')).'</li>';
                @rmdir(ROOT_DIR.'Results/Test');
                echo '<li>'.strval(setupMetaDataFile('Test', TRUE)).'</li>';
            }
            else if ($_POST['submit'] == 'Test lookupTeamIDByName') {
                echo '<li>'.lookupTeamIDByName('Santa Teresa Sea Otters').'</li>';
                echo '<li>'.lookupTeamIDByName('Pinehurst Piranhas-CA').'</li>';
                echo '<li>'.lookupTeamIDByName('Pinehurst').'</li>';
                echo '<li>'.lookupTeamIDByName('Almaden Dolphins').'</li>';
                echo '<li>'.lookupTeamIDByName('BLACH BLACH BLACH').'</li>';
            }
            else if ($_POST['submit'] == 'Test insertNewSwimmer') {
                echo '<li>'.strval(insertNewSwimmer('Nick', 'Svalbard', 2, FALSE)).'</li>';
                echo '<li>'.strval(insertNewSwimmer('Hey', 'You', 5, FALSE)).'</li>';
                echo '<li>'.strval(insertNewSwimmer('What', 'Up', 4)).'</li>';
            }
            else if ($_POST['submit'] == 'Test getNextNickNum') {
                echo '<li>'.strval(getNextNickNum()).'</li>';
            }
             else if ($_POST['submit'] == 'Test insertNewTeam') {
                echo '<li>'.strval(insertNewTeam('Electric Eels', 'Eaglewood')).'</li>';
                echo '<li>'.strval(insertNewTeam('EEE-PC')).'</li>';
            }
            else if ($_POST['submit'] == 'Test lookupEventIDByName') {
                echo '<li>'.strval(lookupEventIDByName('Girls 8 & Under 100 Yard Medley Relay')).'</li>';
                echo '<li>'.strval(lookupEventIDByName('Boys 9-10 25 Yard Freestyle')).'</li>';
            }
            else if ($_POST['submit'] == 'Test getListOfMeets') {
               $meets = getListOfMeets();
               foreach ($meets as $meet)
                    echo '<li>'.$meet['name'].' - '.$meet['date'].'</li>';
            }
            else if ($_POST['submit'] == 'Test compareTimes') {
                    echo '<li>1 - '.(string)compareTimes('1:13.33', '54.33').'</li>';
                    echo '<li>-1 - '.(string)compareTimes('1:13.33', '2:13.33').'</li>';
                    echo '<li>0 - '.(string)compareTimes('1:13.33', '1:13.33').'</li>';
                    echo '<li>-1 - '.(string)compareTimes('1:13.33', '1:13.76').'</li>';
                    echo '<li>1 - '.(string)compareTimes('1:00.33', '59.33').'</li>';
                    echo '<li>0 - '.(string)compareTimes('20.33', '20.33').'</li>';
                    echo '<li>-1 - '.(string)compareTimes('59.33', '59.43').'</li>';
                    echo '<li>1 - '.(string)compareTimes('36.33', '25.33').'</li>';
            }
            else if ($_POST['submit'] == 'Test getListOfRoles') {
               $roles = getListOfRoles();
               foreach ($roles as $role)
                    echo '<li>'.$role['id'].' - '.$role['name'].'</li>';
            }
            else if ($_POST['submit'] == 'Test timeStrToHunds') {
               echo '<li>'.(string)timeStrToHunds('25.33').'</li>';
               echo '<li>'.(string)timeStrToHunds('1:25.33').'</li>';
               echo '<li>'.(string)timeStrToHunds('2.33').'</li>';
               echo '<li>'.(string)timeStrToHunds('2.94').'</li>';
            }
        ?>
        </ul>
    <form action="tester.php" method="post">
    <fieldset>
        <legend>Scan in Events:</legend>
        <ol>
            <li><input type="submit" name="submit" value="Test getEventNameByID" /></li>
            <li><input type="submit" name="submit" value="Test getTeamDetailsByID" /></li>
            <li><input type="submit" name="submit" value="Test lookupSwimIDByName" /></li>
            <li><input type="submit" name="submit" value="Test extractDate" /></li>
            <li><input type="submit" name="submit" value="Test extractTeamInfo" /></li>
            <li><input type="submit" name="submit" value="Test setupMetaDataFile" /></li>
            <li><input type="submit" name="submit" value="Test lookupTeamIDByName" /></li>
            <li><input type="submit" name="submit" value="Test insertNewSwimmer" /></li>
            <li><input type="submit" name="submit" value="Test getNextNickNum" /></li>
            <li><input type="submit" name="submit" value="Test insertNewTeam" /></li>
            <li><input type="submit" name="submit" value="Test lookupEventIDByName" /></li>
            <li><input type="submit" name="submit" value="Test getListOfMeets" /></li>
            <li><input type="submit" name="submit" value="Test compareTimes" /></li>
            <li><input type="submit" name="submit" value="Test getListOfRoles" /></li>
            <li><input type="submit" name="submit" value="Test timeStrToHunds" /></li>
            <li><p><a href="index.php">Cancel</a></p></li>
        </ol>
    </fieldset>
    </form>
    </div>

</div> <!-- End of outer-wrapper which opens in header.php -->

<?php 
    include ("Includes/footer.php");
 ?>